<template>
	<view class="flex-col homepage">
		<u--form>
			<u-form-item class="formItemInput" label="小区" :label-width="70" @click="FindXq">
				<u-input placeholder="请选择" v-model="carinfo.communityName" type="text"></u-input>
			</u-form-item>
			<u-form-item class="formItemInput" label="车位区域" :label-width="70" @click="FindArea">
				<u-input placeholder="请选择" v-model="carinfo.area" type="text"></u-input>
			</u-form-item>
			<u-form-item class="formItemInput-two" label="车位编号" :label-width="70" @click="FindNum">
				<u-input placeholder="请选择" v-model="carinfo.serialNumber" type="text"></u-input>
			</u-form-item>
			<u-form-item class="formItemActionSheet" label="车位类型" :label-width="70" @click="type">
				<u-input placeholder="请选择" v-model="carinfo.vehicleType" type="text"></u-input>
				<!-- <uni-data-select v-model="qqq" :localdata="range" @select="stateSelect"></uni-data-select> -->
				<u-picker :show="show6" :columns="columns" @confirm="confirm" @cancel="cancel"></u-picker>
			</u-form-item>
			<u-form-item class="formItemInput-two" label="绑定车辆" :label-width="70" @click="FindCar">
				<u-input placeholder="请选择" v-model="carinfo.vehicleNumber" type="text"></u-input>
			</u-form-item>
			<view>
				<u--text text="住户信息" style="margin-top:20px;margin-bottom: 10px;"></u--text>
			</view>
			<u-form-item class="formItemInput" label="住户姓名" :label-width="70">
				<u-input type="text" v-model="user.userName"></u-input>
			</u-form-item>
			<u-form-item class="formItemInput" label="手机号码" :label-width="70">
				<u-input type="text" v-model="user.phone"></u-input>
			</u-form-item>
		</u--form>
		<u-button type="primary" text="提交审核" style="width: 300px;" @click="carCommit()"></u-button>
		<view>
			<!-- //小区 -->
			<u-popup :show="show" mode="right">
				<view v-for="(item, index) in this.Community">
					<u-tag :text="item.communityName" plain size="mini" type="warning" class="ttt" @click="xqhx(item)">
					</u-tag>
				</view>
			</u-popup>
			<!-- //车位区域 -->
			<u-popup :show="show2" mode="right">
				<view v-for="(item, index) in this.Area">
					<u-tag :text="item.area" plain size="mini" type="warning" class="ttt" @click="ldhx(item)">
					</u-tag>
				</view>
			</u-popup>
			<!-- //车位编号 -->
			<u-popup :show="show3" mode="right">
				<view v-for="(item, index) in this.Num">
					<u-tag :text="item.serialNumber" plain size="mini" type="warning" class="ttt" @click="lchx(item)">
					</u-tag>
				</view>
			</u-popup>
			<!-- //车辆 -->
			<u-popup :show="show4" mode="right">
				<view v-for="(item, index) in this.Car">
					<u-tag :text="item.vehicleNumber" plain size="mini" type="warning" class="ttt" @click="mhhx(item)">
					</u-tag>
				</view>
			</u-popup>
		</view>


	</view>
</template>
<script>
	export default {
		data() {
			return {
				columns: [
					['私有', '租赁']
				],
				show6: false,
				show: false,
				show2: false,
				show3: false,
				show4: false,
				user: {},
				middleId: '',
				carNumber: false,
				tttt: false,
				single: '',
				sc: '',
				Community: [],
				Area: [],
				Num: [],
				Car: [],
				range: [{
						text: "私有"
					},
					{
						text: "租赁"
					}
				],
				carinfo:{}
				
			}

		},
		onLoad(e) {
			this.user = uni.getStorageSync('user')
			this.carinfo = JSON.parse(decodeURIComponent(e.carinfo));
			this.carinfo.vehicleCarOldId=this.carinfo.vehicleCarId
			this.carinfo.vehicleNumberOldId=this.carinfo.vehicleNumberId
		},
		methods: {
			cancel() {
				this.show6 = false
			},
			confirm(e) {
				this.carinfo.vehicleType = e.value[0]
				this.show6 = false
			},
			type() {
				this.show6 = true
			},
			carCommit() {
				this.user = uni.getStorageSync('user'),
				this.carinfo.userId = this.user.userId
				this.$axios({
					url: 'serverwg/app/car/updateCarportUser',
					data: this.carinfo,
					method: 'POST',
					success: (res) => {
						alert("修改成功")
						uni.navigateTo({
						    url: '../xss/carport'
						})
					}
				})
			},

			FindXq() {
				this.show = true
				this.$axios({
					url: 'serverwg/WjxFindAllCommunity',
					data: {},
					method: 'GET',
					success: (res) => {
						this.Community = res.data.data.Community
					}
				})
			},
			FindArea() {
				this.show2 = true
				this.$axios({
					url: 'serverwg/app/car/findAllArea',
					data: {},
					method: 'GET',
					success: (res) => {
						this.Area = res.data.content
					}
				})
			},
			FindNum() {
				this.show3 = true
				this.$axios({
					url: 'serverwg/app/car/findAllNum',
					data: {},
					method: 'GET',
					success: (res) => {
						this.Num = res.data.content
					}
				})
			},
			FindCar() {
				this.show4 = true
				this.$axios({
					url: 'serverwg/app/car/findAllCar',
					data: {},
					method: 'GET',
					success: (res) => {
						this.Car = res.data.content
					}
				})
			},
			//选择小区
			xqhx(data) {
				this.carinfo.communityId = data.communityId
				this.carinfo.communityName = data.communityName
				this.show = false
			},
			ldhx(data) {
				this.carinfo.vehicleAreaId = data.vehicleAreaId
				this.carinfo.area = data.area
				this.show2 = false
			},
			lchx(data) {
				this.carinfo.vehicleNumberId = data.vehicleNumberId
				this.carinfo.serialNumber = data.serialNumber
				this.show3 = false
			},
			mhhx(data) {
				this.carinfo.vehicleCarId = data.vehicleCarId
				this.carinfo.vehicleNumber = data.vehicleNumber
				this.show4 = false
			}


		}
	}
</script>
<style lang="scss" scoped>
	/** 全局样式-开始,建议放在公共css样式文件中,比如common.css 或app.vue文件 */

	html,
	body {
		margin: 0;
		width: 100%;
		height: 100%;
		font-size: 16px
	}

	view,
	text,
	image {
		position: relative;
		box-sizing: border-box;
		flex-shrink: 0;
	}

	.ttt {
		margin: 10px 30px 10px 30px;
	}

	.flex-col {
		display: flex;
		align-items: flex-start;
		flex-direction: column;
	}

	.flex-row {
		display: flex;
		align-items: flex-start;
	}

	.flex-col .flex-row {
		width: 100%
	}

	/** 全局样式-结束*/

	.homepage {
		height: 1623.188rpx;
		padding: 28.986rpx 0rpx 0rpx 1.812rpx;
		border-color: #ff9900;

		.formItemInput {
			width: 100%;
		}

		.formItemActionSheet {
			width: 100%;
		}

		.formItemInput-two {
			width: 100%;
			margin-bottom: 12.681rpx;
		}

		.wrapper {
			width: 262.681rpx;
			justify-content: space-between;
			margin-bottom: 21.739rpx;

			.text {
				width: 114.13rpx;
				margin-top: 14.493rpx;
			}
		}
	}
</style>
